package com.itheima.listener;

import com.itheima.domain.mongo.VideoScore;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(consumerGroup = "recomment-video-group",topic = "recomment-video")//监听recomment-video队列
public class VideoScoreListener implements RocketMQListener<VideoScore> {
    @Autowired
    private MongoTemplate mongoTemplate;
    @Override//如果topic中添加了信息运行此程序
    public void onMessage(VideoScore videoScore) {
        System.out.println("接收了视频推荐消息"+videoScore);
        mongoTemplate.save(videoScore);
    }
}
